#include <iostream>
#include <vector>

using namespace std;

typedef pair<int, int> PII;
const int N = 5e5 + 10;

int n, m, s;
vector<int> edges[N];
vector<PII> query[N];
bool st[N];
int fa[N], ret[N];

int find(int x)
{
	return fa[x] == x ? x : fa[x] = find(fa[x]);
}

void tarjin(int x)
{
	st[x] = true;
	for(auto y : edges[x])
	{
		if(st[y]) continue;
		tarjin(y);
		fa[y] = x;
	}
	
	for(auto& t : query[x])
	{
		int y = t.first, i = t.second;
		if(st[y]) ret[i] = find(y); 
	}
}

int main()
{
	cin >> n >> m >> s;
	for(int i = 1; i <= n; i++) fa[i] = i;
	for(int i = 1; i < n; i++)
	{
		int a, b; cin >> a >> b;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	
	for(int i = 1; i <= m; i++)
	{
		int a, b; cin >> a >> b;
		query[a].push_back({b, i});
		query[b].push_back({a, i});
	}
	
	tarjin(s);
	
	for(int i = 1; i <= m; i++) cout << ret[i] << endl;
	
	return 0;
}













